import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.npc_man = pygame.image.load("../资源/图片/老头.png").convert_alpha()
        self.npc_woman = pygame.image.load("../资源/图片/老太.png").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()

        self.hero_pos = (3, 0)
        self.up_pos = (6, 0)
        self.down_pos = (4, 0)
        self.variable_pos = {
            (4, 7): (self.door_yellow, '黄门'),
            (6, 7): (self.door_yellow, '黄门'),
            (5, 9): (self.door_red, '红门'),
            (4, 5): (self.gem_red, '红宝石'),
            (6, 5): (self.gem_red, '红宝石'),
            (4, 4): (self.gem_blue, '蓝宝石'),
            (6, 4): (self.gem_blue, '蓝宝石'),
            (4, 3): (self.npc_man, '15楼老头'),
            (6, 3): (self.npc_woman, '15楼老太'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(9):
            self.draw(self.wall, 1, i + 1)
            self.dic[(1, i + 1)] = '墙'
            self.draw(self.wall, 2, i + 1)
            self.dic[(2, i + 1)] = '墙'
            self.draw(self.wall, 3, i + 1)
            self.dic[(3, i + 1)] = '墙'
            self.draw(self.wall, 9, i + 1)
            self.dic[(9, i + 1)] = '墙'
            self.draw(self.wall, 8, i + 1)
            self.dic[(8, i + 1)] = '墙'
            self.draw(self.wall, 7, i + 1)
            self.dic[(7, i + 1)] = '墙'
            if i != 7 and i != 8:
                self.draw(self.wall, 5, i+1)
                self.dic[(5, i+1)] = '墙'
        for i in [(5, 0), (4, 1), (4, 2), (6, 1), (6, 2), (4, 9), (6, 9)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
